<template>
  <div class="home">
    <el-container>
      <el-header>
        <h2>logo</h2>
        <h2>电商后台管理系统</h2>
        <el-button @click="tologin">登出</el-button>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <i class="el-icon-s-operation" @click="isCollapse = !isCollapse"></i>
          <!-- //左侧 -->
          <el-menu default-active="" class="el-menu-vertical-demo" :collapse="isCollapse" router>
            <el-submenu :index="item.path" v-for="item in menuslist" :key="item.id">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>{{ item.authName }}</span>
              </template>
              <el-menu-item-group>
                <template slot="title">
                  <el-menu-item  :index="ele.path" v-for="ele in item.children" :key="ele.id">{{ ele.authName
                  }}</el-menu-item>
                </template>

              </el-menu-item-group>
            </el-submenu>
          </el-menu>

        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { getmenus } from ".././utils/api"
export default {
  data() {
    return {
      isCollapse: false,
      menuslist: []
    }
  },
  methods: {
    //登出
    tologin() {
      window.localStorage.removeItem('token')
      this.$router.push('/')
    },
    //获取列表
    getmenuss() {
      getmenus().then((res) => {
        console.log(res.data.data);
        this.menuslist = res.data.data
      })
    }
  },
  created() {
    this.getmenuss()
  },
  mounted() {

  },
  components: {

  },
  computed: {

  },
  watch: {

  },
}
</script>

<style lang='scss' scoped>
.home {
  width: 100%;
  height: 100%;
  background-color: #fff;
}

.el-header {
  background-color: #363c42;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>
